package com.wuseguang.springcloud.service.impl;

import com.wuseguang.springcloud.quartz.JobOperation;
import com.wuseguang.springcloud.service.HaiweidaCooperativeSchoolService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 海威达合作学校 服务实现类
 * </p>
 *
 * @author 
 * @since 2020-07-02
 */
@Service
public class HaiweidaCooperativeSchoolServiceImpl  implements HaiweidaCooperativeSchoolService {

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private JobOperation jobOperation;

    @Override
    public Result haiweidaCron() {
        //要触发的时间
        List<String> cronList = new ArrayList<>();
        cronList.add("0 0/1 * * * ?");
        try {
            //添加前先把这个以前的删除了
            jobOperation.remove("HaiweidaCooperativeSchoolTimer","haiweida");
            jobOperation.add("HaiweidaCooperativeSchoolTimer","haiweida",cronList);
        } catch (Exception e) {
            logger.error("海威达合作学校定时器创建失败",e);
        }
        return new Result();
    }
}
